package Opeartion;

import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class BorrowBook implements Operation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("借阅图书");
        Scanner scanner =new Scanner(System.in);
        System.out.println("请输入借阅书的名字：");
        String name=scanner.nextLine();

        int currentSize=booklist.getBrrownum();
        for (int i = 0; i < currentSize; i++) {
            if (booklist.getBook(i).getName().equals(name)){
                if(booklist.getBook(i).isIsborrow()){
                    System.out.println("该书已被借出了");
                    return;
                }else {
                    booklist.getBook(i).setIsborrow(true);
                    System.out.println("借阅成功！");
                    return;
                }

            }
        }
        System.out.println("没有你要找的书，借阅失败！");
    }
}
